package flex.persistence.criteria.criteriaQuery {
	import mx.utils.ArrayUtil;
	import mx.utils.StringUtil;
	public class Trimspec {
		protected static var localInstantiation:Boolean = false;
		
		private static var _BOTH:Trimspec; 
		public static function get BOTH():Trimspec {
			if(!_BOTH) { 
				localInstantiation = true;
				_BOTH = new Trimspec("both");
				localInstantiation = false;
			}
			return _BOTH;
		} 
		
		private static var _LEADING:Trimspec; 
		public static function get LEADING():Trimspec {
			if(!_LEADING) { 
				localInstantiation = true;
				_LEADING = new Trimspec("leading");
				localInstantiation = false;
			}
			return _LEADING;
		} 
		
		private static var _TRAILING :Trimspec; 
		public static function get TRAILING ():Trimspec {
			if(!_TRAILING ) { 
				localInstantiation = true;
				_TRAILING  = new Trimspec("trailing");
				localInstantiation = false;
			}
			return _TRAILING ;
		} 

		public static function valueOf(name:String):Trimspec {
			for each(var val:Trimspec in values()) {
				if(val.name.toUpperCase() == name.toUpperCase()) return val;
			}
			return null;
		}
		
		public static function values():Array {
			return [LEADING, BOTH, TRAILING];
		}
		
		protected var name:String;
		public function Trimspec(name:String) {
			if(!localInstantiation) throw Error("Private constructor");
			this.name = name;
		}
		
		public function toString():String {
			return this.name;
		}
		
		public function equals(obj:Object):Boolean {
			return this.name == obj.name;
		}
	}
}